package com.eascs.overdue.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eascs.admin.o2o.loan.dao.O2oLoanUserDao;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;
import com.eascs.common.util.StringUtil;
import com.eascs.overdue.dao.O2oOverdueDao;
import com.eascs.overdue.entity.O2oOverdueFormEntity;
import com.eascs.overdue.entity.O2oOverdueReport;
import com.eascs.pay.dao.O2oPayDao;

@Service
public class O2oOverdueService {
	@Autowired
	private O2oPayDao o2oPayDao;
	@Autowired
	private O2oOverdueDao  o2oOverdueDao;
	@Autowired
	private O2oLoanUserDao o2oLoanUserDao;
	public PageResult<Object[]> getPageOverdue(O2oOverdueFormEntity entity) {
		StringBuffer querySql = new StringBuffer();
		querySql.append("SELECT T.BILL_CODE,T.regional_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.PENALTY_INTEREST,T.DISPOSAL_AMOUNT,T.`STATUS`,T.DISPOSAL_DATE,T.SOURCE_TYPE,T.UNITNO FROM (");
		querySql.append(" SELECT LBI.BILL_CODE,opr.regional_name as regional_name,LBI.OPERATOR_PROVINCE, ");
		querySql.append(" CONCAT(S.UNITCODE,'-',S.NAMECN) AS OPERATOR_AGENCY, ");
		querySql.append(" S.UNITNO  as UNITNO, ");
		querySql.append(" CONCAT(LBI.CRMOTOLOANERSUR,LBI.CRMOTOLOANER) AS LOAN_NAME, ");
		querySql.append(" LBI.IDCARD,LBI.BANKREFUND,LBI.LOAN_AMOUNT,LBI.LOAN_TIME, ");
		querySql.append(" DATE_ADD(LBI.LOAN_TIME,INTERVAL LOAN_TERM MONTH) AS LOAN_LONGT_IME, ");
		querySql.append(" IFNULL(BIO.DEFAULT_AMOUT,0) AS DEFAULT_AMOUT,IFNULL(BIO.OVERDUE_PRINCIPAL,0) AS OVERDUE_PRINCIPAL,IFNULL(BIO.OVERDUE_INTEREST,0) AS OVERDUE_INTEREST, ");
		querySql.append(" IFNULL(BIO.PENALTY_INTEREST,0) AS PENALTY_INTEREST,IFNULL(BIO.DISPOSAL_AMOUNT,0) AS DISPOSAL_AMOUNT,BIO.`STATUS`,BIO.DISPOSAL_DATE, ");
		querySql.append(" (CASE WHEN LBI.SOURCE_TYPE=0 THEN '老系统' WHEN LBI.SOURCE_TYPE=1 THEN '新系统' END) AS SOURCE_TYPE ");
		querySql.append(" FROM BASIC_INFORMATION_OVERDUE AS BIO INNER JOIN LOAN_BASE_INFO  ");
		querySql.append(" AS LBI ON LBI.BILL_CODE = BIO.BILLCODE ");
		querySql.append(" JOIN HR_UNITS S ON S.UNITNO = LBI.OPERATOR_AGENCY ");
		querySql.append(" left join o2o_platform_regional opr  on opr.platform_id = LBI.operator_agency ");
		querySql.append(" WHERE LBI.ISLOCK = 'N' AND BIO.IS_NEW = 'Y'  GROUP BY BIO.BILLCODE ORDER BY BIO.OP_TIME DESC ) AS T WHERE /**DATA_PERMISSION(T.UNITNO)**/ 1=1");
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageOldIndex());
		if (!StringUtil.isEmpty(entity.getBankFun())) {
			querySql.append(" AND T.BANKREFUND = ? ");
			sqlPageQuery.addParam(entity.getBankFun());
		}
		if (!StringUtil.isEmpty(entity.getBillCode())) {
			querySql.append(" AND T.BILL_CODE LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getBillCode());
		}
		if (!StringUtil.isEmpty(entity.getLoanName())) {
			querySql.append(" AND T.LOAN_NAME LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getLoanName());
		}
		if (!StringUtil.isEmpty(entity.getStatus())) {
			querySql.append(" AND T.`STATUS` = ? ");
			sqlPageQuery.addParam(entity.getStatus());
		}
		/*if (!StringUtil.isEmpty(entity.getProvince())) {
			querySql.append(" AND T.OPERATOR_PROVINCE = ? ");
			sqlPageQuery.addParam(entity.getProvince());
		}*/
		if (!StringUtil.isEmpty(entity.getRegionalName())) {
			querySql.append(" AND T.regional_name = ? ");  
			sqlPageQuery.addParam(entity.getRegionalName());
		}
		if (!StringUtil.isEmpty(entity.getNamecn())) {
			querySql.append(" AND T.OPERATOR_AGENCY LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getNamecn());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return o2oPayDao.findDataWithPage(sqlPageQuery);
	}
	
	
	public PageResult<Object[]> getPageO2oOverdue(O2oOverdueFormEntity entity) {
		StringBuffer querySql = new StringBuffer();
		querySql.append("SELECT T.BILL_CODE,T.regional_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.PENALTY_INTEREST,T.DISPOSAL_AMOUNT,T.`STATUS`,T.DISPOSAL_DATE,T.SOURCE_TYPE FROM (");
		querySql.append(" SELECT LBI.BILL_CODE, ");
		querySql.append(" opr.regional_name as regional_name, ");
		querySql.append(" CONCAT(LBI.ltd_name) AS OPERATOR_AGENCY,BIO.ltd as ltd,");
		querySql.append(" os.user_full_name AS LOAN_NAME, ");
		querySql.append(" os.document_no as IDCARD ,LBI.bank_loan_name as BANKREFUND ,LBI.loana_mount as LOAN_AMOUNT ,LBI.payment_time as LOAN_TIME , ");
		querySql.append(" BIO.maturitydate as LOAN_LONGT_IME, ");
		querySql.append(" IFNULL(BIO.defaultamount,0) AS DEFAULT_AMOUT,IFNULL(BIO.defaultcapital,0) AS OVERDUE_PRINCIPAL,IFNULL(BIO.defaultinterest,0) AS OVERDUE_INTEREST, ");
		querySql.append(" IFNULL(BIO.penaltyinterest,0) AS PENALTY_INTEREST,IFNULL(BIO.disposalamoun,0) AS DISPOSAL_AMOUNT,BIO.`STATUS`,BIO.disposaldate as DISPOSAL_DATE ,'新系统' as SOURCE_TYPE ");
		querySql.append(" FROM o2o_overdue_report AS BIO INNER JOIN o2o_loanapply    ");
		querySql.append(" AS LBI ON LBI.BILL_CODE = BIO.BILLCODE  ");
		querySql.append(" left join o2o_loan_user os  on os.loan_id = LBI.loan_id ");
		querySql.append(" left join o2o_platform_regional opr  on opr.platform_id = BIO.ltd ");
		querySql.append(" WHERE LBI.ISLOCK = 'N' AND BIO.ISNEW = 'Y' ORDER BY BIO.disposaldate DESC ) AS T WHERE /**DATA_PERMISSION(T.ltd)**/ 1=1 ");
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		if (!StringUtil.isEmpty(entity.getBankFun())) {
			querySql.append(" AND T.BANKREFUND = ? ");
			sqlPageQuery.addParam(entity.getBankFun());
		}
		if (!StringUtil.isEmpty(entity.getBillCode())) {
			querySql.append(" AND T.BILL_CODE LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getBillCode());
		}
		if (!StringUtil.isEmpty(entity.getLoanName())) {
			querySql.append(" AND T.LOAN_NAME LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getLoanName());
		}
		if (!StringUtil.isEmpty(entity.getStatus())) {
			querySql.append(" AND T.`STATUS` = ? ");
			sqlPageQuery.addParam(entity.getStatus());
		}
		if (!StringUtil.isEmpty(entity.getNamecn())) {
			querySql.append(" AND T.OPERATOR_AGENCY LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getNamecn());
		}
		
		if (!StringUtil.isEmpty(entity.getRegionalName())) {
			querySql.append(" AND T.regional_name = ? ");  
			sqlPageQuery.addParam(entity.getRegionalName());
		}
		
		sqlPageQuery.setQuerySql(querySql.toString());
		return o2oPayDao.findDataWithPage(sqlPageQuery);
	}
	
	/**
	 * 20170104
	 * @return
	 */
	public PageResult<Object[]> getPageO2oOverdueNew(O2oOverdueFormEntity entity) {
		StringBuffer querySql = new StringBuffer();
		/*querySql.append("SELECT T.BILL_CODE,T.regional_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.`STATUS`,T.DISPOSAL_DATE FROM (");*/
		querySql.append("SELECT T.loanapplyno,T.BILL_CODE,T.province_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.PENALTY_INTEREST,T.DISPOSAL_AMOUNT,T.`STATUS`,T.DISPOSAL_DATE,T.TIMEFRAME,T.province_code From (");
		querySql.append(" SELECT LBI.BILL_CODE,BIO.loanapplyno as  loanapplyno,");
		querySql.append(" opr.province_name as province_name,opr.province_code as province_code, ");
		querySql.append(" CONCAT(LBI.ltd_code,'-',LBI.ltd_name) AS OPERATOR_AGENCY, BIO.ltd as ltd,");
		querySql.append(" os.user_full_name AS LOAN_NAME, ");
		querySql.append(" os.document_no as IDCARD ,LBI.bank_loan_name as BANKREFUND ,LBI.loana_mount as LOAN_AMOUNT ,LBI.payment_time as LOAN_TIME , ");
		querySql.append(" BIO.maturitydate as LOAN_LONGT_IME, ");
		querySql.append(" IFNULL(BIO.defaultamount,0) AS DEFAULT_AMOUT,IFNULL(BIO.defaultcapital,0) AS OVERDUE_PRINCIPAL,IFNULL(BIO.defaultinterest,0) AS OVERDUE_INTEREST, ");
		querySql.append(" IFNULL(BIO.penaltyinterest,0) AS PENALTY_INTEREST,IFNULL(BIO.disposalamoun,0) AS DISPOSAL_AMOUNT,BIO.`STATUS`,BIO.disposaldate as DISPOSAL_DATE ,BIO.timeframe as TIMEFRAME");
		querySql.append(" FROM o2o_overdue_report AS BIO INNER JOIN o2o_loanapply    ");
		querySql.append(" AS LBI ON LBI.BILL_CODE = BIO.BILLCODE  ");
		querySql.append(" left join o2o_loan_user os  on os.loan_id = LBI.loan_id and LBI.loanapply_no = os.loanapply_no  and os.spouse_id is null and os.sponsor_type is null ");
		querySql.append(" left join o2o_platform_regional opr  on opr.platform_id = BIO.ltd ");
		querySql.append(" WHERE LBI.ISLOCK = 'N' AND BIO.ISNEW = 'Y' ORDER BY BIO.disposaldate DESC ) AS T WHERE /**DATA_PERMISSION(T.ltd)**/ 1=1 ");
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		if (!StringUtil.isEmpty(entity.getBankFun())) {
			querySql.append(" AND T.BANKREFUND = ? ");
			sqlPageQuery.addParam(entity.getBankFun());
		}
		if (!StringUtil.isEmpty(entity.getBillCode())) {
			querySql.append(" AND T.BILL_CODE LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getBillCode());
		}
		if (!StringUtil.isEmpty(entity.getLoanName())) {
			querySql.append(" AND T.LOAN_NAME LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getLoanName());
		}
		if (!StringUtil.isEmpty(entity.getStatus())) {
			querySql.append(" AND T.`STATUS` = ? ");
			sqlPageQuery.addParam(entity.getStatus());
		}
		if (!StringUtil.isEmpty(entity.getNamecn())) {
			querySql.append(" AND T.OPERATOR_AGENCY LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getNamecn());
		}
		
		if (!StringUtil.isEmpty(entity.getRegionalName())) {
			querySql.append(" AND T.province_code = ? ");  
			sqlPageQuery.addParam(entity.getRegionalName());
		}
		
		sqlPageQuery.setQuerySql(querySql.toString());
		return o2oPayDao.findDataWithPage(sqlPageQuery);
	}
	
	
	/**
	 * 20170109 yy
	 * @return
	 */
	public PageResult<Object[]> findByPageReportList(O2oOverdueFormEntity entity) {
		StringBuffer querySql = new StringBuffer();
		/*querySql.append("SELECT T.BILL_CODE,T.regional_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.`STATUS`,T.DISPOSAL_DATE FROM (");*/
		querySql.append("SELECT T.BILL_CODE,T.province_name,T.OPERATOR_AGENCY,T.LOAN_NAME,T.IDCARD,T.BANKREFUNDNAME,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.PENALTY_INTEREST,T.DISPOSAL_AMOUNT,T.`statusName`,T.DISPOSAL_DATE,T.province_code From (");
		querySql.append(" SELECT LBI.BILL_CODE, ");
		querySql.append(" opr.province_name as province_name,opr.province_code as province_code,  ");
		querySql.append(" CONCAT(LBI.ltd_code,'-',LBI.ltd_name) AS OPERATOR_AGENCY,BIO.ltd as ltd,");
		querySql.append(" os.user_full_name AS LOAN_NAME, ");
		querySql.append(" os.document_no as IDCARD ,(SELECT d.item_name FROM PUB_DDITEM d WHERE d.DD_NO = 10340 AND d.item_code = LBI.bank_loan_name ) AS BANKREFUNDNAME,LBI.bank_loan_name AS BANKREFUND ,LBI.loana_mount as LOAN_AMOUNT ,DATE_FORMAT(LBI.payment_time,'%Y-%m-%d') as LOAN_TIME , ");
		querySql.append(" DATE_FORMAT(BIO.maturitydate,'%Y-%m-%d') as LOAN_LONGT_IME, ");
		querySql.append(" IFNULL(BIO.defaultamount,0) AS DEFAULT_AMOUT,IFNULL(BIO.defaultcapital,0) AS OVERDUE_PRINCIPAL,IFNULL(BIO.defaultinterest,0) AS OVERDUE_INTEREST, ");
		querySql.append(" IFNULL(BIO.penaltyinterest,0) AS PENALTY_INTEREST,IFNULL(BIO.disposalamoun,0) AS DISPOSAL_AMOUNT,(SELECT d.item_name FROM PUB_DDITEM_o2o d WHERE d.DD_NO = 1160 AND d.item_code = BIO.`STATUS` ) as `statusName`,BIO.`STATUS`  as `status`,DATE_FORMAT(BIO.disposaldate,'%Y-%m-%d') AS DISPOSAL_DATE ,'新系统' as SOURCE_TYPE ");
		querySql.append(" FROM o2o_overdue_report AS BIO INNER JOIN o2o_loanapply    ");
		querySql.append(" AS LBI ON LBI.BILL_CODE = BIO.BILLCODE  ");
		querySql.append(" left join o2o_loan_user os on os.loan_id = LBI.loan_id and LBI.loanapply_no = os.loanapply_no  and os.spouse_id is null and os.sponsor_type is null ");
		querySql.append(" left join o2o_platform_regional opr  on opr.platform_id = BIO.ltd ");
		querySql.append(" WHERE LBI.ISLOCK = 'N' AND BIO.ISNEW = 'Y' ORDER BY BIO.disposaldate DESC ) AS T WHERE /**DATA_PERMISSION(T.ltd)**/ 1=1 ");
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		if (!StringUtil.isEmpty(entity.getBankFun())) {
			querySql.append(" AND T.BANKREFUND = ? ");
			sqlPageQuery.addParam(entity.getBankFun());
		}
		if (!StringUtil.isEmpty(entity.getBillCode())) {
			querySql.append(" AND T.BILL_CODE LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getBillCode());
		}
		if (!StringUtil.isEmpty(entity.getLoanName())) {
			querySql.append(" AND T.LOAN_NAME LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getLoanName());
		}
		if (!StringUtil.isEmpty(entity.getStatus())) {
			querySql.append(" AND T.`STATUS` = ? ");
			sqlPageQuery.addParam(entity.getStatus());
		}
		if (!StringUtil.isEmpty(entity.getNamecn())) {
			querySql.append(" AND T.OPERATOR_AGENCY LIKE ? ");
			sqlPageQuery.addLikeParam(entity.getNamecn());
		}
		
		if (!StringUtil.isEmpty(entity.getRegionalName())) {
			querySql.append(" AND T.province_code = ? ");  
			sqlPageQuery.addParam(entity.getRegionalName());
		}
		
		sqlPageQuery.setQuerySql(querySql.toString());
		return o2oPayDao.findDataWithPage(sqlPageQuery);
	}
	
	/**
	 * 根据billcode逾期信息
	 * @param billCode
	 * @return
	 */
	public O2oOverdueReport queryBillCode(String billCode){
		String sql="select * from o2o_overdue_report t where t.billcode=?";
		return o2oPayDao.findEntity(sql, O2oOverdueReport.class, billCode);
	}
	

	/**
	 * @Title: queryOverDue
	 * @Description: 根据billCode查询主申请人和配偶的逾期信息
	 * @author 张庆奇
	 * @param billCode
	 * @param showPage
	 * @return
	 * @return PageResult<Object[]>
	 * @throws
	 * @date 2017年1月9日 下午2:17:43
	 */
	public PageResult<Object[]> queryOverDue(String billCode){
		String idnums = "";
		O2oLoanapplyEntity loanApply = (O2oLoanapplyEntity) o2oLoanUserDao
				.findEntity("select * from o2o_loanapply l  where l.bill_code=? ", O2oLoanapplyEntity.class, billCode);
		if (loanApply != null) {
			O2oLoanUserEntity user = o2oLoanUserDao.queryLoanpplyNo( loanApply.getLoanapplyNo(),loanApply.getLoanId());
			O2oLoanUserEntity mateUser = o2oLoanUserDao.findSpouseId(loanApply.getLoanId(), loanApply.getLoanapplyNo());
			if (user != null) {
				if (StringUtil.isNotBlank(user.getDocumentNo())) {
					idnums = user.getDocumentNo();
				}
			}
			if (mateUser != null) {
				if (StringUtil.isNotBlank(mateUser.getDocumentNo())) {
					if (StringUtil.isNotBlank(idnums)) {
						idnums = idnums + "," + mateUser.getDocumentNo();
					} else {
						idnums = mateUser.getDocumentNo();
					}
				}
			}

		} else {
			return new PageResult<Object[]>();
		}
		if (StringUtil.isEmpty(idnums)) {
			return new PageResult<Object[]>();
		}
		return o2oOverdueDao.queryOverdue(idnums);
	}
	
	public PageResult<Object[]> getO2oOverduePage(O2oOverdueFormEntity entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), 0);
		StringBuffer querySql = new StringBuffer();
		querySql.append(" select * from ( "); //去重子查询
		querySql.append("SELECT T.loanapplyno,T.BILL_CODE,T.LOAN_NAME,T.BANKREFUND,T.LOAN_AMOUNT,T.LOAN_TIME,T.LOAN_LONGT_IME,T.DEFAULT_AMOUT, ");
		querySql.append(" T.`STATUS`,T.DISPOSAL_DATE,T.isnew,T.province_code From (");
		querySql.append(" SELECT LBI.BILL_CODE,BIO.loanapplyno as  loanapplyno,");
		querySql.append(" opr.province_name as province_name,opr.province_code as province_code, ");
		querySql.append(" CONCAT(LBI.ltd_name) AS OPERATOR_AGENCY, BIO.ltd as ltd,");
		querySql.append(" os.user_full_name AS LOAN_NAME, ");
		querySql.append(" os.document_no as IDCARD ,LBI.bank_loan_name as BANKREFUND ,LBI.loana_mount as LOAN_AMOUNT ,LBI.payment_time as LOAN_TIME , ");
		querySql.append(" BIO.maturitydate as LOAN_LONGT_IME, ");
		querySql.append(" IFNULL(BIO.defaultamount,0) AS DEFAULT_AMOUT,IFNULL(BIO.defaultcapital,0) AS OVERDUE_PRINCIPAL,IFNULL(BIO.defaultinterest,0) AS OVERDUE_INTEREST, ");
		querySql.append(" IFNULL(BIO.penaltyinterest,0) AS PENALTY_INTEREST,IFNULL(BIO.disposalamoun,0) AS DISPOSAL_AMOUNT,BIO.`STATUS`,BIO.disposaldate as DISPOSAL_DATE ,BIO.timeframe as TIMEFRAME,BIO.isnew");
		querySql.append(" FROM o2o_overdue_report_interim AS BIO INNER JOIN o2o_loanapply    ");
		querySql.append(" AS LBI ON LBI.BILL_CODE = BIO.BILLCODE  ");
		querySql.append(" left join o2o_loan_user os  on os.loan_id = LBI.loan_id and LBI.loanapply_no = os.loanapply_no  and os.spouse_id is null and os.sponsor_type is null ");
		querySql.append(" left join o2o_platform_regional opr  on opr.platform_id = BIO.ltd ");
		querySql.append(" WHERE LBI.ISLOCK = 'N'  ORDER BY BIO.disposaldate DESC ) AS T WHERE 1=1 AND T.idcard in( ?, ?) GROUP BY T.BILL_CODE,T.TIMEFRAME ORDER BY T.TIMEFRAME DESC ");
		querySql.append(" )ove GROUP BY ove.DISPOSAL_DATE ,ove.STATUS,ove.DEFAULT_AMOUT "); //去重子查询
		
		sqlPageQuery.addParam(entity.getIdCard());
		sqlPageQuery.addParam(entity.getSpouseIdCard());
		sqlPageQuery.setQuerySql(querySql.toString());
		return o2oPayDao.findDataWithPage(sqlPageQuery);
	}
}
